package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LuntaiExampleImage;
import com.ruoyi.system.service.ILuntaiExampleImageService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 示例图片Controller
 * 
 * @author ruoyi
 * @date 2025-03-20
 */
@RestController
@RequestMapping("/system/image")
public class LuntaiExampleImageController extends BaseController
{
    @Autowired
    private ILuntaiExampleImageService luntaiExampleImageService;

    /**
     * 查询示例图片列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LuntaiExampleImage luntaiExampleImage)
    {
        startPage();
        List<LuntaiExampleImage> list = luntaiExampleImageService.selectLuntaiExampleImageList(luntaiExampleImage);
        return getDataTable(list);
    }

    /**
     * 导出示例图片列表
     */
    @Log(title = "示例图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LuntaiExampleImage luntaiExampleImage)
    {
        List<LuntaiExampleImage> list = luntaiExampleImageService.selectLuntaiExampleImageList(luntaiExampleImage);
        ExcelUtil<LuntaiExampleImage> util = new ExcelUtil<LuntaiExampleImage>(LuntaiExampleImage.class);
        util.exportExcel(response, list, "示例图片数据");
    }

    /**
     * 获取示例图片详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(luntaiExampleImageService.selectLuntaiExampleImageById(id));
    }

    /**
     * 新增示例图片
     */
    @Log(title = "示例图片", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LuntaiExampleImage luntaiExampleImage)
    {
        return toAjax(luntaiExampleImageService.insertLuntaiExampleImage(luntaiExampleImage));
    }

    /**
     * 修改示例图片
     */
    @Log(title = "示例图片", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody LuntaiExampleImage luntaiExampleImage)
    {
        return toAjax(luntaiExampleImageService.updateLuntaiExampleImage(luntaiExampleImage));
    }

    /**
     * 删除示例图片
     */
    @Log(title = "示例图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(luntaiExampleImageService.deleteLuntaiExampleImageByIds(ids));
    }
}
